﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SameGame
{
	/// <summary>
	/// Interaction logic for BallUserControl.xaml
	/// </summary>
	public partial class BallUserControl : UserControl
	{
		private int _column;
		private int _row;
		private BoardUserControl _boardControl;

		public BallUserControl(BoardUserControl boardControl)
		{
			InitializeComponent();
			_boardControl = boardControl;
		}

		public int Column
		{
			get { return _column; }
			set { _column = value; }
		}

		public int Row
		{
			get { return _row; }
			set { _row = value; }
		}

		public int ColorType
		{
			get { return ellipse.ColorType; }
			set
			{
				ellipse.ColorType = value;
			}
		}

		public bool IsHighlighted
		{
			get
			{
				return ellipse.IsHiLighted;
			}
			set
			{
				ellipse.IsHiLighted = value;
			}
		}

		private void BallUserControl_MouseEnter(object sender, MouseEventArgs e)
		{
			_boardControl.OnEnterHighlight(_column, _row);
		}

		private void BallUserControl_MouseLeave(object sender, MouseEventArgs e)
		{
			_boardControl.OnLeaveHighlight(_column, _row);
		}

		private void UserControl_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
		{
			_boardControl.OnBallClick(_column, _row);
		}

		internal void ClearEvents()
		{
			this.MouseEnter -= BallUserControl_MouseEnter;
			this.MouseLeave -= BallUserControl_MouseLeave;
			this.MouseLeftButtonDown -= UserControl_MouseLeftButtonDown_1;
		}
	}
}
